﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Smarts.Controls.Properties;

namespace Smarts.Controls
{
    /// <summary>
    /// Provides a visual representation of a boolean value
    /// in a 16 x 16 icon
    /// </summary>
    public partial class BooleanVisualizer : UserControl
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public BooleanVisualizer()
        {
            InitializeComponent();
        }
        private bool _value = false;
        private bool _valueSet = false;

        /// <summary>
        /// The boolean value to display
        /// </summary>
        public bool Value
        {
            get
            {
                return _value;
            }
            set
            {
                _valueSet = true;
                _value = value;
                setImage();
            }
        }

        private void setImage()
        {
            if (_valueSet)
            {
                if (_value)
                {
                    imgRepresentation.Image = Resources.tick;
                }
                else
                {
                    imgRepresentation.Image = Resources.cross;
                }
            }
            else
            {
                imgRepresentation.Image = Resources.help;
            }
        }

        /// <summary>
        /// Whether a value has been set. Automatically set
        /// to true when the Value property is set
        /// </summary>
        public bool ValueSet
        {
            get
            {
                return _valueSet;
            }
            set
            {
                _valueSet = value;
                setImage();
            }
        }
    }
}
